package com.example.web.mapper;

import com.example.web.entity.StockOut;
import com.example.web.entity.StockOutDet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface Smapper {
    @Select("""
           SELECT c.price
            FROM stockoutdet s
            JOIN cargo c ON s.CargoId = c.Id
            WHERE s.CargoId = #{id}
            ORDER BY s.id DESC -- 根据stockoutdet表的id字段降序排序，确保最大的id对应的记录排在前面
            LIMIT 1 -- 只取第一条记录，也就是id最大的那条记录对应的结果
            """)
    public Double selectPriceById(int id);
    @Select("select * from stockoutdet where StockOutId = #{id}")
    public StockOutDet selectByStockOutDetId(int id);
}
